﻿using University.Workshop.Business;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using University.Workshop.Model;

namespace University.Workshop.Tests
{
    
    
    /// <summary>
    ///This is a test class for PrivacySettingsManagerTest and is intended
    ///to contain all PrivacySettingsManagerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class PrivacySettingsManagerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetPrivacySettingByEmail
        ///</summary>
        [TestMethod()]
        public void GetPrivacySettingByEmailSuccessTest()
        {
            Random rand = new Random();
            string email = "diroag" + rand.Next(500) + "@hotmail.com";
            DateTime birthday = Convert.ToDateTime("04/05/1996");
            UserRegistrationManager.RegisterUser("minombre", "miapellido", 'M',
                                         birthday, email, "qwerty12", "qwerty12", "Cochabamba",
                                         "Cercado", "7222222", "4401492");
            PrivacySetting expected = new PrivacySetting { Setting = "000000000" }; // TODO: Initialize to an appropriate value
            PrivacySetting actual;
            actual = PrivacySettingsManager.GetPrivacySettingByEmail(email);
            Assert.AreEqual(expected.Setting, actual.Setting);
        }

        /// <summary>
        ///A test for GetPrivacySettingByEmail
        ///</summary>
        [TestMethod()]
        public void GetPrivacySettingByEmailFailTest()
        {
            PrivacySetting expected = null;
            PrivacySetting actual;
            actual = PrivacySettingsManager.GetPrivacySettingByEmail("someWrong@Email.com");
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for SetPrivacySettingByEmail
        ///</summary>
        [TestMethod()]
        public void SetPrivacySettingByEmailSuccessTest()
        {
            Random rand = new Random();
            string email = "diroag" + rand.Next(500) + "@hotmail.com"; 
            DateTime birthday = Convert.ToDateTime("04/05/1992");
            UserRegistrationManager.RegisterUser("minombre", "miapellido", 'M',
                                         birthday, email, "qwerty12", "qwerty12", "Cochabamba",
                                         "Cercado", "7222222", "4401492");
            string setting = "101010101"; // some setting
            PrivacySetting actual;
            actual = PrivacySettingsManager.SetPrivacySettingByEmail(email, setting);
            PrivacySetting expected = PrivacySettingsManager.GetPrivacySettingByEmail(email);
            Assert.AreEqual(expected.Setting, actual.Setting);
            Assert.AreEqual(expected.UserId, actual.UserId);
            Assert.AreEqual(expected.PrivacyId, actual.PrivacyId);
        }

        /// <summary>
        ///A test for SetPrivacySettingByEmail
        ///</summary>
        [TestMethod()]
        public void SetPrivacySettingByEmailFailTest()
        {
            string setting = "101010101"; // some setting
            PrivacySetting actual;
            actual = PrivacySettingsManager.SetPrivacySettingByEmail("someWrong@email.com", setting);
            PrivacySetting expected = null;
            Assert.AreEqual(expected, actual);
        }
    }
}
